'\"macro stdmacro
.\"
.\" Copyright (c) 2022 Red Hat.
.\" Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMPARSETIME 3 "PCP" "Performance Co-Pilot"
.SH NAME
\f3__pmtimevalParse\f1,
\f3__pmtimespecParse\f1 \- parse time point specification
.SH "C SYNOPSIS"
.ft 3
.ad l
.hy 0
#include "pmapi.h"
.br
#include "libpcp.h"
.sp
int __pmtimevalParse(const char *\fIstring\fP,
'in +\w'int __pmtimevalParse('u
struct\ timeval\ *\fIlogStart\fP,
struct\ timeval\ *\fIlogEnd\fP,
struct\ timeval\ *\fIrslt\fP,
char\ **\fIerrMsg\fP);
.in
.br
int __pmtimespecParse(const char *\fIstring\fP,
'in +\w'int __pmtimespecParse('u
struct\ timespec\ *\fIlogStart\fP,
struct\ timespec\ *\fIlogEnd\fP,
struct\ timespec\ *\fIrslt\fP,
char\ **\fIerrMsg\fP);
.in
.sp
cc ... \-lpcp
.hy
.ad
.ft 1
.SH CAVEAT
This documentation is intended for internal Performance Co-Pilot
(PCP) developer use.
.PP
These interfaces are not part of the PCP APIs that are guaranteed to
remain fixed across releases, and they may not work, or may provide
different semantics at some point in the future.
.SH DESCRIPTION
.B __pmtimevalParse
and
.B __pmtimespecParse
are designed to encapsulate the interpretation of a time point specification
in command line switches for use by the PCP client tools.
.P
These functions expects to be called with the time point specification as
.BR string .
If the tool is running against PCP archive(s), you also
need to supply the start time of the first (only) archive as
.BR logStart ,
and the end of the last (only) archive as
.BR logEnd .
See
.BR pmGetArchiveLabel (3)
and
.BR pmGetArchiveEnd (3)
for how to obtain values for these parameters.
If the tool is running against a live feed of performance data,
.B logStart
should be the current time (but could be aligned on the next second
for example), while
.B logEnd
should have its tv_sec component set to PM_MAX_TIME_T.
.P
The
.B rslt
structure must be allocated before either calling
.B __pmtimevalParse
or
.BR __pmtimespecParse .
.P
You also need to set the current PCP reporting time zone to correctly
reflect the \-z and \-Z command line parameters before calling
.B __pmtimevalParse
or
.BR __pmtimespecParse .
See
.BR pmUseZone (3)
and friends for information on how this is done.
.P
If the conversion is successful, both
.B __pmtimevalParse
and
.B __pmtimespecParse
return 0, and fill in
.B rslt
with the time value defined by the input parameters.
If the argument strings could not be parsed, it returns \-1
and a dynamically allocated error message string in
.BR errMsg .
Be sure to
.BR free (3)
this error message string.
.SH SEE ALSO
.BR PMAPI (3),
.BR __pmParseCtime (3),
.BR __pmtimespecConvert (3),
.BR __pmtimevalConvert (3),
.BR pmGetArchiveEnd (3),
.BR pmGetArchiveLabel (3),
.BR pmNewContextZone (3),
.BR pmNewZone (3),
.BR pmParseInterval (3),
.BR pmParseTimeWindow (3)
and
.BR pmUseZone (3).
